package com.xcw.jac;

import java.text.ParseException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * @author xcw
 * @date 2023/7/24 11:14
 * @description
 */
public class jaaa {
    public static void main(String[] args) throws ParseException {
        String s = "下载区间是：{}-{}";
        String a = "abc";
        String b = "abcd";
        String afterMsg = s.replace("{}", "%s");
        String format = String.format(afterMsg, a, b);
        System.out.println(s);
        System.out.println(format);

    }
    public static void pri(String msg, String... args) {
        System.out.println(msg);
    }

    /**
     * 默认的命名规则：命名后缀改带IP后两位，IP：xx1.xx2.xx3.xx4 格式：名称 + _ + xx3 + _ + xx4。
     * @param serverName
     * @param ip
     * @return
     */
    private static String defaultNameConvention(String serverName, String ip) {

        String data = serverName;
        if (ip != "") {
            if (ip == null){
                return serverName;
            }
            String[] ipArr = ip.split("\\.");
            if (ipArr.length != 4){
                return serverName;
            }
            String s1 = completion3len(ipArr[ipArr.length - 2]);
            String s2 = completion3len(ipArr[ipArr.length -1]);
            data = serverName + "_" + s1 + "_" + s2;
        }

        return data;
    }

    // 补全三位
    private static String completion3len(String str) {
        switch (str.length()) {
            case 1:
                return "00" + str;
            case 2:
                return "0" + str;
            default:
                return str;
        }
    }
}
